<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Validation : CodeIgniter User Guide</title>

<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />

<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>

<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>

<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.0.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->


<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
Form Validation
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->

<br clear="all" />


<!-- START CONTENT -->
<div id="content">

<h1>폼 검증 </h1>

<p>CodeIgniter는 포괄적인 폼 검증및 데이터 준비 클래스를 제공함으로써 작성하시는 코드의 양을 최소화 하도록 해 줍니다.</p>

<p class="important"><strong>주의:</strong>&nbsp;  CodeIgniter 1.7.0 이후 에서는 ,이전 버전의 폼검증 클래스와 달라졌습니다. 이전 버전의 클래스도 남겨두었기때문에 작동하는데는 문제가 없으나 새 폼검증 클래스를 사용하실것을 권장합니다.</p>

<ul>
<li><a href="#overview">개요 Overview</a></li>
<li><a href="#tutorial">폼검증 튜토리얼 Form Validation Tutorial</a>

	<ul>
		<li><a href="#theform">폼 The Form</a></li>
		<li><a href="#thesuccesspage">성공 페이지 The Success Page</a></li>
		<li><a href="#thecontroller">컨트롤러 The Controller</a></li>
		<li><a href="#validationrules">검증규칙 설정 Setting Validation Rules</a></li>
		<li><a href="#validationrulesasarray">배열을 이용한 검증규칙 설정 Setting Validation Rules Using an Array</a></li>
		<li><a href="#cascadingrules">중첩 규칙 Cascading Rules</a></li>
		<li><a href="#preppingdata">데이터 준비 Prepping Data</a></li>
		<li><a href="#repopulatingform">폼데이터를 다시 살리기 Re-populating the Form</a></li>
		<li><a href="#callbacks">콜백 Callbacks</a></li>
		<li><a href="#settingerrors">에러메세지 설정 Setting Error Messages</a></li>
		<li><a href="#errordelimiters">에러 구분자의 변경 Changing the Error Delimiters</a></li>
		<li><a href="#translatingfn">필드명의 변환 Translating Field Names</a></li>
		<li><a href="#individualerrors">에러를 각각 보여주기 Showing Errors Individually</a></li>
		<li><a href="#savingtoconfig">Config 파일에 검증규칙을 저장하기 Saving Sets of Validation Rules to a Config File</a></li>
		<li><a href="#arraysasfields">배열을 필드이름으로 사용하기 Using Arrays as Field Names</a></li>
	</ul>
</li>
<li><a href="#rulereference">규칙 참조 Rule Reference</a></li>
<li><a href="#preppingreference">데이터준비 참조 Prepping Reference</a></li>
<li><a href="#functionreference">함수 참조 Function Reference</a></li>
<li><a href="#helperreference">헬퍼 참조 Helper Reference</a></li>

</ul>






<p>&nbsp;</p>

<a name="overview"></a>
<h1>개요 Overview</h1>


<p>CodeIgniter 의 폼 검증 설명으로 들어가기전에 먼저 이상적인 시나리오를 만들어봅시다:</p>

<ol>
<li>폼이 표시된다.</li>
<li>내용을 채우고 전송(submit)한다.</li>
<li>뭔가 적합하지않은것을 전송한다든지, 필수인항목을 빠뜨린다든지 했을경우 , 폼이 다시 표시되면서 관련 에러메세지를 뿌려준다.</li>
<li>정확하게 전송할때까지 이 과정을 반복한다.</li>
</ol>

<p>수신측에서의 스크립트는 반드시:</p>

<ol>
<li>요구되는 데이터가 모두 들어왔는지 점검한다.</li>
<li>데이터의 형식이라든지 다른 요구되는 제한사항을 만족하는지 확인한다. 예를들어, 만약 사용자아이디(username)이 전송되었고 반드시 영문자만을 포함해야한다고 제한한다든지, 최소 최대길이를 지정한다든지, 이미 다른사람이 사용하고 있는아이디를 사용할수 없다든지,예약어를 사용할수 없다든지 등의경우가 있을수 있다.</li>
<li>보안을 위해서 데이터를 가공한다.</li>
<li>필요하다면 데이터를 전처리 한다(좌우공백제거나 html 인코딩 등)</li>
<li>데이터베이스 입력에 적합하도록 데이터를 준비한다.</li>
</ol>


<p>위 프로세스가 그리 복잡하지는 않지만, 일반적으로 대단히많은 소스코드가 필요하고 ,에러코드를 표시하기위해서 다양한 컨트롤 구조를 html 안에 코딩해야한다. 폼검증코드는 쉬운작업인 반면에 통상 그 양이 방대하고 지루한 작업이다.</p>

<p>&nbsp;</p>


<a name="tutorial"></a>
<h1>폼검증 튜토리얼 Form Validation Tutorial</h1>

<p>아래는 CodeIgniter 의 폼검증을 구현하기 위한 &quot;수작업&quot; 튜토리얼 입니다.</p>


<p>폼검을 위해서는 아래 3가지 요소가 필요합니다:</p>

<ol>
<li>폼을 포함한 <a href="../general/views.html">뷰</a> 파일.</li>
<li>전송이 성공했을때 &quot;성공&quot;메세지를 보여줄 파일.</li>
<li>전송된 데이터를 받아서 처리할<a href="../general/controllers.html"> 컨트롤러</a> 함수.</li>
</ol>

<p>회원가입폼 예제를 통해서 이 세가지를 만들어 봅시다!</p>



<a name="theform"></a>

<h2>폼 The Form</h2>

<p>텍스트 편집기를 이용하여 <dfn>myform.php</dfn>파일을 만듭니다. 그런다음 아래 코드를 삽입하고 <samp>applications/views/</samp>
폴더에 저장합니다:</p>


<textarea class="textarea" style="width:100%" cols="50" rows="30">&lt;html>
&lt;head>
&lt;title>My Form&lt;/title>
&lt;/head>
&lt;body>

&lt;?php echo validation_errors(); ?>

&lt;?php echo form_open('form'); ?>

&lt;h5>Username&lt;/h5>
&lt;input type="text" name="username" value="" size="50" />

&lt;h5>Password&lt;/h5>
&lt;input type="text" name="password" value="" size="50" />

&lt;h5>Password Confirm&lt;/h5>
&lt;input type="text" name="passconf" value="" size="50" />

&lt;h5>Email Address&lt;/h5>
&lt;input type="text" name="email" value="" size="50" />

&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>

&lt;/form>

&lt;/body>
&lt;/html>
</textarea>




<a name="thesuccesspage"></a>
<h2>성공 페이지 The Success Page</h2>


<p>텍스트 편집기를 이용하여<dfn>formsuccess.php</dfn>파일을 만듭니다. 그런다음 아래 코드를 삽입하고<samp>applications/views/</samp>
폴더에 저장합니다:</p>


<textarea class="textarea" style="width:100%" cols="50" rows="14">
&lt;html>
&lt;head>
&lt;title>My Form&lt;/title>
&lt;/head>
&lt;body>

&lt;h3>Your form was successfully submitted!&lt;/h3>

&lt;p>&lt;?php echo anchor('form', 'Try it again!'); ?>&lt;/p>

&lt;/body>
&lt;/html>
</textarea>



<a name="thecontroller"></a>
<h2>컨트롤러 The Controller</h2>

<p>텍스트 편집기를 이용하여<dfn>form.php</dfn>파일을 만듭니다. 그런다음 아래 코드를 삽입하고<samp>applications/controllers/</samp>폴더에 저장합니다:</p>


<textarea class="textarea" style="width:100%" cols="50" rows="21">&lt;?php

class Form extends CI_Controller {
	
	function index()
	{
		$this->load->helper(array('form', 'url'));
		
		$this->load->library('form_validation');
				
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('myform');
		}
		else
		{
			$this->load->view('formsuccess');
		}
	}
}
?></textarea>


<h2>해봅세 ! Try it!</h2>

<p> 브라우저에서 아래와 같은 URL 로 접속합니다(여러분의 환경에 맞는 url 입니다. 아래 그대로가 아니라 ..):</p>

<code>example.com/index.php/<var>form</var>/</code>

<p><dfn>폼을 전송(submit) 하면 단순히 폼이 리로드(reload) 되는것을 보실수 있습니다.  왜나하면 아직 검사(validation) 루틴을 작성하지 않았기 때문입니다.</dfn></p>

<p><strong>폼 검사 클래스에 어떤 검사코드도 넣지 않았기때문에 결과는 <kbd>FALSE</kbd> (boolean false) 를 기본값으로 리턴합니다.검사코드를 성공적으로 통과했을 경우에만 <samp>run()</samp>
함수는<kbd>TRUE</kbd> 를 리턴합니다.</strong></p>


<h2>설명 Explanation</h2>

<p>위 페이지들로부터 여러가지를 아실수 있을거예요:</p>

<p><dfn>폼</dfn> (myform.php) 은 몇가지 예외들을 포함한 표준 웹폼(standard web form) 입니다:</p>

<ol>
<li>폼은 폼을 여는 태그 대신 <dfn>폼헬퍼(form helper</dfn>) 를 사용합니다.
엄밀히말하면, 폼 헬퍼 사용은 꼭 필요하지 않을수 있습니다.  표준 html 을 이용하여 폼을 열수 있으니까요.  그러나, 폼헬퍼를 사용하면 설정(config)파일에 따라서 액션url(action URL)을 자동으로 생성해줍니다.  그렇게 되면 URL 이 변하더라도 쉽게 처리할 수 있겠지요.</li>

<li>폼의 맨위에 아래와 같은 함수호출이 있는것을 주목하세요 :
<code>&lt;?php echo validation_errors(); ?&gt;</code>

<p>이 함수는 검사(validator)루틴으로 부터 되돌아오는 모든 에러메세지를 리턴합니다. 아무런 메세지가 없다면 빈문자열(empty string)을 리턴합니다.</p>
</li>
</ol>

<p><dfn>컨트롤러controller</dfn> (form.php)는 <dfn>index()</dfn>라는 함수를 가지고 있습니다. 이함수는 뷰파일에서 사용할 검사클래스(validation class)를 초기화 하고 <var>폼 헬퍼</var> 와 <var>URL 헬퍼</var>를 로드합니다. 또한 검사루틴을 실행(<samp>runs)</samp>
합니다. 검사루틴을 성공적으로 패스했는지 여부에 따라서 폼 자신이나 성공 페이지를 보여줍니다.</p>




<a name="validationrules"></a>

<h2>검사루틴(규칙) 설정 Setting Validation Rules</h2>

<p>검사규칙은 원하는 만큼 제한없이 작성하실수 있으며 , 각 규칙들을 순서대로 처리하도록 할수 있습니다. 또한, 검사와 동시에 필드 데이터들을 전처리(pre-process)할수 있습니다. 검사규칙을 설정하기 위해서는<dfn>set_rules()</dfn> 함수를 사용합니다:</p>

<code>$this->form_validation->set_rules();</code>

<p> 위 함수는 3가지 파라미터를 받습니다:</p>

<ol>
	<li>필드이름-폼에서 설정한 필드이름과 일치해야합니다.</li>
	<li>위 필드이름에 대한  &quot;사람이 알아보기 쉬운&quot; 이름. 그 이름은 에러메세지에 삽입됩니다. 예를들어, 필드이름이&quot;user" 라면 사람이 알아보기쉬운이름은 "Username" 정도로 하시면 됩니다. <strong>부가설명:</strong> 필드이름을 랭귀지파일에 저장하고싶다면, <a href="#translatingfn">필드이름변환</a>을 참조하세요. </li>
	<li>폼에 필요한 검사규칙들.</li>
</ol>
<p><br />
예제를 봐주세요. <dfn>컨트롤러</dfn> (form.php) 파일에 아래와같이 검사루틴을 초기화 시켜주세요:</p>

<code>
$this->form_validation->set_rules('username', 'Username', 'required');<br />
$this->form_validation->set_rules('password', 'Password', 'required');<br />
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
$this->form_validation->set_rules('email', 'Email', 'required');<br />
</code>

<p> 컨트롤러는 아래와 비슷할것입니다:</p>

<textarea class="textarea" style="width:100%" cols="50" rows="28">&lt;php

class Form extends CI_Controller {
	
	function index()
	{
		$this->load->helper(array('form', 'url'));
		
		$this->load->library('form_validation');
			
		$this->form_validation->set_rules('username', 'Username', 'required');
		$this->form_validation->set_rules('password', 'Password', 'required');
		$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
		$this->form_validation->set_rules('email', 'Email', 'required');
			
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('myform');
		}
		else
		{
			$this->load->view('formsuccess');
		}
	}
}
?></textarea>

<p><dfn>자 이제 필드를 공백으로둔 채 폼을 전송해봅시다. 에러메세지가 보여야 합니다. 만약 필드를 모두 채운상태에서 전송한다면 성공페이지가 보여야 합니다.</dfn></p>

<p class="important"><strong>주의:</strong> 지금까지로는 에러가 발생했을경우, 폼에 이미 입력한데이터는 다시 복원되지않습니다. 곧 복원되도록 만들어 봅시다ㅎㅎ.</p>




<a name="validationrulesasarray"></a>
<h2>배열을 이용하여 검사규칙설정하기 Setting Rules Using an Array</h2>

<p>여러 검사규칙을 한번에 처리하는걸 좋아한다면, 배열을 사용하세요.
이 방법을 사용할때는 <strong>반드시</strong> 배열의 키이름을 아래와같이 해야합니다:</p>

<code>
$config = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
<br />
$this->form_validation->set_rules($config);
</code>






<a name="cascadingrules"></a>
<h2>규칙의 순차적 적용 Cascading Rules</h2>

<p>규칙을 여러개의 파이프라인처럼 연결해서 같이 적용할수 있습니다.  해볼까요. 아래와같이, 규칙설정함수의 세번째 파라미터를 아래와 같이 바꾸세요:</p>

<code>
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');<br />
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');<br />
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');<br />
</code>

<p>위코드는 다음의 규칙을 설정합니다:</p>

<ol>
<li>Username 필드는 5 글자에서 12 글자 사이라야 한다.</li>
<li>Password 필드는 패스워드 확인 필드와 일치해야한다.</li>
<li>Email 필드는 유효한 email 주소라야 한다.</li>
</ol>

<p>해봅세! 적절하지 않은 데이터를 입력한후 폼을 전송하시면 여러분이 새로 설정한 규칙에 맞는 에러메시지를 뿌릴것입니다.
 레퍼런스에는 사용가능한 다양한 규칙들이 있습니다.</p>



<a name="preppingdata"></a>
<h2>데이터 준비 Prepping Data</h2>

<p>위에서 사용해본 검사함수에 덧붙여, 여러분은 다양한 방법으로 데이터준비작업을 하실 수 있습니다.예를 들어, 아래와같이 규칙을 설정할 수 있습니다:</p>

<code>
$this->form_validation->set_rules('username', 'Username', '<kbd>trim</kbd>|required|min_length[5]|max_length[12]|<kbd>xss_clean</kbd>');<br />
$this->form_validation->set_rules('password', 'Password', '<kbd>trim</kbd>|required|matches[passconf]|<kbd>md5</kbd>');<br />
$this->form_validation->set_rules('passconf', 'Password Confirmation', '<kbd>trim</kbd>|required');<br />
$this->form_validation->set_rules('email', 'Email', '<kbd>trim</kbd>|required|valid_email');<br />
</code>


<p>위 예제에서 , 필드의 좌우공백제거(trim), 암호를 MD5 로 변환, 부적합한 데이터를제거하기위해 username 에 "xss_clean" 함수적용시키기등을 수행했습니다.</p>

<p><strong>일반 PHP 함수중에 하나의 파라미터를 받는 함수라면 어떤것이라도 규칙처럼 사용할수 있습니다. 예를들어 <dfn>htmlspecialchars</dfn>,
<dfn>trim</dfn>,  <dfn>MD5</dfn>, 등입니다.</strong></p>

<p><strong>참고:</strong> 일반적으로 검증규칙을 적용시킨후 데이터준비(prep)함수를 사용하게 됩니다. 이때 만약 에러가 발생한다면 원래데이터가 폼에 표시되게 됩니다.</p>




<a name="repopulatingform"></a>
<h2>폼 데이터 복원하기 Re-populating the form</h2>

<p>지금까지는 에러관련부분 처리에 대해서 이야기해왔습니다.이제는 전송된 데이터를 다시 복원하는것에 대해서 이야기하겠습니다. CodeIgniter 에서는 그 작업을 위해서 여러가지 헬퍼함수를 제공합니다. 여러분이 가장 많이 사용할 함수는 아래함수입니다:</p>

<code>set_value('field name')</code>


<p><dfn>myform.php</dfn> 뷰 파일을 연후 각 필드의<strong>value</strong> 부분을 <dfn>set_value()</dfn> 함수를 사용하여 업데이트합니다 :</p>

<p><strong><dfn>set_value()</dfn> 함수의 파라미터로 필드이름을 넘겨줘야한다는것 잊지마세요!</strong></p>


<textarea class="textarea" style="width:100%" cols="50" rows="30">
&lt;html>
&lt;head>
&lt;title>My Form&lt;/title>
&lt;/head>
&lt;body>

&lt;?php echo validation_errors(); ?>

&lt;?php echo form_open('form'); ?>

&lt;h5>Username&lt;/h5>
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />

&lt;h5>Password&lt;/h5>
&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />

&lt;h5>Password Confirm&lt;/h5>
&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />

&lt;h5>Email Address&lt;/h5>
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />

&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>

&lt;/form>

&lt;/body>
&lt;/html>
</textarea>


<p><dfn>에러를 발생시키기 위해서 폼을 새로고침한후 전송하세요 .  이제 폼필드의 데이터들은 복원될것입니다.</dfn></p>

<p class="important"><strong>주의:</strong>아래의  <a href="#functionreference">함수참조</a> 부분에서 &lt;select> menus, radio button,  checkbox 의 데이터를 복원하는 부분을 확인하세요.</p>


<p><strong>중요사항:</strong> 필드의 이름에 배열을 사용했다면 , 함수에도 배열형태 그대로를 넘겨줍니다.</p>
<p>예:</p>
<code>&lt;input type="text" name="<kbd>colors[]</kbd>" value="&lt;?php echo set_value('<kbd>colors[]</kbd>'); ?>" size="50" /></code>

<p>더많은 정보는 아래의 <a href="#arraysasfields">필드이름으로 배열사용하기</a> 에 있습니다.</p>





<a name="callbacks"></a>
<h2>콜백(처리가 완료되면 자동으로 호출될함수지정)Callbacks: Your own Validation Functions</h2>

<p>검증시스템은 콜백을지원합니다. 이를 통해 검증클래스를 어려분의 필요에 따라 확장하는것이 가능합니다. 예를들어, 만약 사용자가 유일한 아이디를 선택했는지를 확인하기위해 데이터베이스 쿼리가 필요하다면, 그 기능을 위한 콜백함수를 만들수 있습니다.예제를 만들어 봅시다.</p>

<p>컨트롤러에서, "username" 규칙을 아래와같이 바꿉니다:</p>

<code>$this->form_validation->set_rules('username', 'Username', '<kbd>callback_username_check</kbd>');</code>


<p>그런후 컨트롤러에 <dfn>username_check</dfn> 라는 함수를 추가합니다.  그러면 컨트롤러는 아래예제와 비슷해질것입니다:</p>


<textarea class="textarea" style="width:100%" cols="50" rows="44">&lt;php

class Form extends CI_Controller {
	
	function index()
	{
		$this->load->helper(array('form', 'url'));
		
		$this->load->library('form_validation');
			
		$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
		$this->form_validation->set_rules('password', 'Password', 'required');
		$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
		$this->form_validation->set_rules('email', 'Email', 'required');
					
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('myform');
		}
		else
		{
			$this->load->view('formsuccess');
		}
	}
	
	function username_check($str)
	{
		if ($str == 'test')
		{
			$this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
	
}
?></textarea>

<p><dfn>폼을 새로고침한후 사용자명에 &quot;test&quot; 라고 입력하고 전송합니다.  필드데이터가 콜백함수에 전달되는것을 확인하실수 있습니다. 콜백함수에서 필요에따라 그 데이터를 처리하시면 되겠죠 . </dfn></p>

<p><strong>콜백을 호출하기위해서는 규칙에 있는 함수명을 "callback_" 라는 접두어와 함께 넣어주시면됩니다.</strong></p>

<p>여러분은 콜백으로 전달되는 폼 데이터를 처리하거나 리턴할수 있습니다. 콜백함수가 불린(boolean TRUE/FALSE) 외의 어떤 값을 리턴하더라도 원본의 폼데이터가 아니라 새롭게 처리된 데이터라고 가정합니다. </p>




<a name="settingerrors"></a>
<h2>에러메세지 설정 Setting Error Messages</h2>


<p>모든 내장 에러메세지는 아래의 언어파일에 있습니다 :  <dfn>language/english/form_validation_lang.php</dfn></p>

<p>에러메세지를 설정하기위하여 위 파일을 수정하거나, 아래함수를 이용할 수 있습니다:</p>

<code>$this->form_validation->set_message('<var>rule</var>', '<var>Error Message</var>');</code>

<p><var>규칙(rule)</var>이름과 그 규칙과 관련하여 표시하고자하는  <var>에러메세지(Error Message)</var>를 넘겨주시면 됩니다.</p>

<p>에러문자열에서 <dfn>%s</dfn> 를 사용하시면, 규칙을 설정할때 썼던 &quot;사람이 알아보기쉬운이름&quot; 으로 대체될것입니다.</p>

<p>위 "callback" 예제에서  에러메세지는 함수이름을 넘겨주어 설정했습니다:</p>

<code>$this->form_validation->set_message('username_check')</code>

<p>언어파일(language file)에 있는 모든 에러메세지는 재정의될수 있습니다.예를들어 , "required" 규칙에 대한 메세지를 바꾸려면 아래와같이합니다 :</p>

<code>$this->form_validation->set_message('required', 'Your custom message here');</code>



<a name="translatingfn"></a>
<h2>필드이름 변환 Translating Field Names</h2>

<p> <dfn>set_rules()</dfn> 함수에서 사용하였던 &quot;사람이 알아보기 쉬운이름&quot;을 언어파일에 저장하여 필드이름 변환이 적용되도록 하고싶다면 아래와 같이 합니다.:</p>

<p>먼저, "사람이 알아보기쉬운이름(human) " 에 아래의 예제와 같이  <dfn>lang:</dfn>이라는 접두어를 붙입니다:</p>

<code>
$this->form_validation->set_rules('first_name', '<kbd>lang:</kbd>first_name', 'required');<br />
</code>

<p>그런다음, 그 이름을 언어파일의 배열에 저장합니다(접두어는 붙이지 않습니다):</p>

<code>$lang['first_name'] = 'First Name';</code>

<p><strong>참고:</strong> 여러분의 언어파일에 저장된 배열 아이템은 CI 에서 자동으로 로드하지않습니다. 컨트롤러에서 아래와같이 로드하셔야 한다는것을 기억하세요:</p>

<code>$this->lang->load('file_name');</code>

<p><a href="language.html">언어클래스(Language Class)</a> 에 언어파일에 대해 더 자세한 정보가 있습니다.</p>


<a name="errordelimiters"></a>
<h2>에러 구분자 바꾸기 Changing the Error Delimiters</h2>

<p>기본적으로 폼 검증 클래스는 에러메세지를 &lt;p&gt; 태그로 감쌉니다. 여러분은 이를 전역적으로 적용되도록 바꿀수도 있고 각각의 메세지에 적용되도록 바꿀수도 있습니다.</p>

<ol>

<li>에러구분자를 전역적으로 바꾸기 <strong>Changing delimiters Globally</strong>

  <p>컨트롤러에서 에러구분자를 전역적으로 바꾸는것은 폼검증 클래스를 로드 한후 아래와 같은 함수호출을 추가하시면 됩니다:</p>

<code>$this->form_validation->set_error_delimiters('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>');</code>

<p>이 예제에서는 div 태그를 사용하도록 바꾸었습니다.</p>
</li>

<li><strong>각각의 에러에 적용되도록 구분자 바꾸기 Changing delimiters Individually</strong>

  <p>아래 두개의 에러생성함수를 통해서 각각의 에러에 적용되는 구분자를 설정할수 있습니다:</p>

<code>&lt;?php echo form_error('field name', '<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>

<p>Or:</p>

<code>&lt;?php echo validation_errors('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>

</li>
</ol>




<a name="individualerrors"></a>
<h2>에러를 각각 표시하기 Showing Errors Individually</h2>

<p>에러메세지를 목록처럼 표시하지않고 각 필드 옆에 표시하려면 <dfn>form_error()</dfn> 함수를 사용합니다.</p>

<p>사용해보자구요! 폼을 아래와 같이 바꿉니다:</p>

<textarea class="textarea" style="width:100%" cols="50" rows="18">
&lt;h5>Username&lt;/h5>
&lt;?php echo form_error('username'); ?>
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />

&lt;h5>Password&lt;/h5>
&lt;?php echo form_error('password'); ?>
&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />

&lt;h5>Password Confirm&lt;/h5>
&lt;?php echo form_error('passconf'); ?>
&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />

&lt;h5>Email Address&lt;/h5>
&lt;?php echo form_error('email'); ?>
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />
</textarea>

<p>에러가 없다면 아무것도 표시되지 않습니다.에러가 있다면 메세지가 표시되겠죠 .</p>

<p><strong>중요사항:</strong> 폼필드 이름으로 배열을 사용한다면, 함수 파라미터로 넘겨주는 이름도 배열 그대로라야 합니다. 예:</p>

<code>&lt;?php echo form_error('<kbd>options[size]</kbd>'); ?><br />
&lt;input type="text" name="<kbd>options[size]</kbd>" value="&lt;?php echo set_value("<kbd>options[size]</kbd>"); ?>" size="50" />
</code>

<p><a href="#arraysasfields">폼필드 이름으로 배열 사용하기</a> 섹션에 더 자세한 정보가 있습니다.</p>




<p>&nbsp;</p>


<a name="savingtoconfig"></a>
<h1>검사규칙셋을 설정파일에 저장하기 Saving Sets of Validation Rules to a Config File</h1>

<p>폼 검증클래스의 장점중 하나는 프로그램에 사용되는 모든 검증규칙을 하나의 설정파일에 저장할수 있다는점 입니다. 이런 규칙들을 그룹으로 묶을 수 있습니다.  이 그룹들은 필요할때 여러분이 직접 로드 할수도 있고 ,일치하는 controller/function 가 호출되었을때 자동으로 로드되게 할수도 있습니다.</p>

<h3>규칙들을 저장하는 방법 How to save your rules</h3>

<p>먼저 <dfn>application/config/</dfn> 폴더 안에  <kbd>form_validation.php</kbd> 파일을 만듧니다.그리고 파일안에 <kbd>$config</kbd> 라는 이름의 배열을 만들어 규칙들을 집어넣습니다. 앞서 보여드린것과 같이 , 검증 배열은 아래와 같은 형태를 가집니다:</p>

<code>
$config = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
</code>

<p><dfn>검증규칙파일은 run() 함수를 호출하면 자동으로 로드되어 적용됩니다.</dfn></p>

<p class="important">배열의 이름은 <strong>반드시</strong> $config 라야 합니다.</p>

<h3>검증규칙 셋 작성 Creating Sets of Rules</h3>

<p>검증규칙을 모아서 하나의 셋으로 만들려면 그것들을 하나의 하위배열(sub arrays)로 만들어야합니다.  아래 예제는 두개의 규칙셋을 포함합니다.
하위배열이름인 "signup" 과 "email"은 임시로 대충붙인이름입니다. ㅎㅎ.  여러분은 여러분이 원하시는 다른 이름을 붙이시면되요 :</p>


<code>$config = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>signup</kbd>' => array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
</code>


<h3>특정 규칙 그룹 호출하기 Calling a Specific Rule Group</h3>

<p>특정규칙그룹을 호출하기위해서는 그룹이름을 <kbd>run()</kbd> 함수의 파라미터로 넘겨줍니다 .  예를 들어 ,<kbd>signup</kbd> 규칙그룹을 호출하려면 아래와같이 합니다:</p>

<code>
if ($this->form_validation->run('<kbd>signup</kbd>') == FALSE)<br />
{<br />
&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
}<br />
</code>



<h3>컨트롤러 함수와 규칙그룹을 연관시키기 Associating a Controller Function with a Rule Group</h3>

<p>규칙그룹을 호출할때 좀더 자동화된 방법을 사용할수 있습니다. 컨트롤러의 class/function 이름 대로 규칙셋의 이름을 부여하시면 됩니다.  예를들어,컨트롤러 이름이  <kbd>Member</kbd> 이고 함수이름이 <kbd>signup</kbd>일때  컨트롤러 클래스는 아래와 같을것입니다:</p>

<code>
&lt;?php<br /><br />
class <kbd>Member</kbd> extends CI_Controller {<br />
<br />
&nbsp;&nbsp;&nbsp;function <kbd>signup</kbd>()<br />
&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('form_validation');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($this->form_validation->run() == FALSE)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
}<br />
?></code>

<p>그러면 검사 설정파일에서는 , 규칙그룹을 <kbd>member/signup</kbd>라는 이름으로 만듭니다 : </p>


<code>$config = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>member/signup</kbd>' = array(<br />
&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
</code>

<p><dfn>규칙그룹이름이 클래스/함수 이름과 완전히 동일하다면 run() 함수만 호출해도 자동으로 적용됩니다.</dfn></p>

<p>&nbsp;</p>


<a name="arraysasfields"></a>
<h1>필드이름으로 배열 사용하기 Using Arrays as Field Names</h1>

<p>폼 검증 클래스는 필드명으로 배열을 사용할수 있도록 지원합니다. 다음예제를 보시죠:</p>

<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="" size="50" /></code>

<p>만약 필드이름으로 배열을 사용하신다면 , 필드명을 요구하는 <a href="#helperreference">헬퍼함수</a>에 정확히 동일한 필드명을 전달해야합니다. 또한 검증규칙 필드명도 동일해야합니다.</p>
<p>예를들어, 위 필드에대한 규칙을 설정한다면 아래와 같이 합니다:</p>
<code>$this->form_validation->set_rules('<kbd>options[]</kbd>', 'Options', 'required');</code>

<p>혹은 위 필드에 대한 에러메세지를 보여주기위해서는 다음과 같이합니다:</p>

<code>&lt;?php echo form_error('<kbd>options[]</kbd>'); ?></code>

<p>또한 데이터복원에 있어서는 다음과 같이 합니다:</p>

<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="<kbd>&lt;?php echo set_value('<kbd>options[]</kbd>'); ?></kbd>" size="50" /></code>

<p>필드이름으로 다차원 배열을 사용할수도 있습니다. 예:</p>

<code>&lt;input type="text" name="<kbd>options[size]</kbd>" value="" size="50" /></code>

<p>혹은:</p>

<code>&lt;input type="text" name="<kbd>sports[nba][basketball]</kbd>" value="" size="50" /></code>

<p>첫번째 예제에서보듯이 여러분은 반드시 헬퍼함수의 파라미터를 배열명과 정확히 일치하도록 해야합니다.:</p>

<code>&lt;?php echo form_error('<kbd>sports[nba][basketball]</kbd>'); ?></code>

<p>여러개의 옵션을 가진 체크박스를 사용한다면 각 옵션뒤의 대괄호[] 는 속이 비어있는채로 두셔야한다는것을 잊지마세요 .그래야만 선택한것들이 모두  POST 배열에 추가되게 됩니다.:</p>

<code>
&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="red" /><br />
&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="blue" /><br />
&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="green" />
</code>

<p>아래와 같이 다차원배열을 사용하실수도 있습니다:</p>

<code>
&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="red" /><br />
&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="blue" /><br />
&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="green" />
</code>

<p>헬퍼함수에서도 또한 빈 대괄호를 포함해야겠지요:</p>

<code>&lt;?php echo form_error('<kbd>options[color][]</kbd>'); ?></code>




<p>&nbsp;</p>


<a name="rulereference"></a>
<h1>규칙 참조 Rule Reference</h1>

<p>다음은 CI에 내장된 규칙목록 입니다:</p>



<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
<tr>
<th>규칙</th>
<th>파라미터</th>
<th>설명(여기서 문자라는것은 숫자,문자,기호등 모두 포함합니다)</th>
<th>예제</th>
</tr><tr>

<td class="td"><strong>required</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 비어있으면 FALSE 를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr><tr>

<td class="td"><strong>matches</strong></td>
<td class="td">Yes</td>
<td class="td">검사대상이 파라미터의 값과 일치하지않을때 FALSE 를 리턴 합니다</td>
<td class="td">matches[form_item]</td>
</tr><tr>

<td class="td"><strong>min_length</strong></td>
<td class="td">Yes</td>
<td class="td">검사대상의 길이가 파라미터 값보다 작을때 FALSE를 리턴 합니다</td>
<td class="td">min_length[6]</td>
</tr><tr>

<td class="td"><strong>max_length</strong></td>
<td class="td">Yes</td>
<td class="td">검사대상의 길이가 파라미터 값보다 클때 FALSE를 리턴 합니다 .</td>
<td class="td">max_length[12]</td>
</tr><tr>

<td class="td"><strong>exact_length</strong></td>
<td class="td">Yes</td>
<td class="td">검사대상의 길이가 파라미터값과 다를때 FALSE를 리턴 합니다 .</td>
<td class="td">exact_length[8]</td>
</tr><tr>
<tr>
		<td class="td"><strong>greater_than</strong></td>
		<td class="td">Yes</td>
      <td class="td">검사대상이 지정된 값보다 작거나 숫자가 아닌 경우 FALSE를리턴 합니다.</td>
		<td class="td">greater_than[8]</td>
	</tr>

	<tr>
		<td class="td"><strong>less_than</strong></td>
		<td class="td">Yes</td>
      <td class="td">검사대상이 지정된 값보다 크거나 숫자가 아닌 경우 FALSE를리턴 합니다.</td>
		<td class="td">less_than[8]</td>
	</tr>
<td class="td"><strong>alpha</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 알파벳 이외의 문자를 포함할대 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr><tr>

<td class="td"><strong>alpha_numeric</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 알파벳이나 숫자가 아닌 문자를 포함할때 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr><tr>

<td class="td"><strong>alpha_dash</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 알파벳,숫자,밑줄(_),대쉬(-) 이외의 문자를 포함할때 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>numeric</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 숫자이외의 문자를포함할때 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>integer</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 정수이외의 문자를 포함할때 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr>
	<tr>
		<td class="td"><strong>decimal</strong></td>
		<td class="td">Yes</td>
      <td class="td">검사대상이 파라미터값과 일치하지 않으면 FALSE를 리턴 합니다.t</td>
		<td class="td">&nbsp;</td>
	</tr>
<tr>
<td class="td"><strong>is_natural</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 자연수 이외의 문자를 포함할때 FALSE를 리턴 합니다 ( 0, 1, 2, 3, 등 인지 검사).</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>is_natural_no_zero</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 1 이상의 자연수 이외의 문자를 포함할때 FALSE를 리턴 합니다 (1, 2, 3, 등 인지 검사).</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>valid_email</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 유효한 Email 주소가 아닐때 FALSE를 리턴 합니다 .</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>valid_emails</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 콤마(,)로 구분된 Email 주소일 경우에 사용하며 유효한 email 주소가 아닐때 FALSE를 리턴 합니다.</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>valid_ip</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 유효한 IP주소가 아닐때 FALSE를 리턴 합니다 .</td>
<td class="td">&nbsp;</td>
</tr>

<tr>
<td class="td"><strong>valid_base64</strong></td>
<td class="td">No</td>
<td class="td">검사대상이 Base64 에 사용되는 문자 이외의 문자를 포함할때 FALSE를 리턴 합니다 .</td>
<td class="td">&nbsp;</td>
</tr>


</table>

<p><strong>참고:</strong> 이 규칙들은 별도의 함수로서 호출할 수도 있습니다. 예제:</p>

<code>$this->form_validation->required($string);</code>

<p class="important"><strong>참고:</strong> PHP 내장함수중 하나의 파라미터를 받는 함수라면 어떤 것도 여기서 사용할수 있습니다.</p>



<p>&nbsp;</p>

<a name="preppingreference"></a>
<h1>데이터 준비 레퍼런스 Prepping Reference</h1>

<p>다음목록은 사용가능한 데이터준비함수들 입니다.:</p>



<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
<tr>
<th>이름</th>
<th>파라미터</th>
<th>설명</th>
</tr><tr>

<td class="td"><strong>xss_clean</strong></td>
<td class="td">No</td>
<td class="td"><a href="input.html">입력클래스(Input Class) </a>페이지에 설명된 것처럼 데이터를 XSS 필터링 합니다.</td>
</tr><tr>

<td class="td"><strong>prep_for_form</strong></td>
<td class="td">No</td>
<td class="td">폼필드에 표시될수 있도록 특수문자를 변환합니다.</td>
</tr><tr>

<td class="td"><strong>prep_url</strong></td>
<td class="td">No</td>
<td class="td">URL에 "http://"가 없으면 추가해 줍니다.</td>
</tr><tr>

<td class="td"><strong>strip_image_tags</strong></td>
<td class="td">No</td>
<td class="td">이미지 태그를 제거하고 이미지 url 을 추출합니다.</td>
</tr><tr>

<td class="td"><strong>encode_php_tags</strong></td>
<td class="td">No</td>      <td class="td">PHP 태그를 HTML 엔터티로 변환합니다.</td>
</tr>

</table>

<p class="important"><strong>참고:</strong> 하나의 파라미터만 받는 PHP 내장함수도 사용하실 수 있습니다 . <kbd>trim</kbd>, <kbd>htmlspecialchars</kbd>, <kbd>urldecode</kbd>, 등.</p>







<p>&nbsp;</p>

<a name="functionreference"></a>
<h1>함수 레퍼런스 Function Reference</h1>

<p>다음함수들은 컨트롤러에서 사용할 수 있습니다.</p>

<h2>$this->form_validation->set_rule();</h2>

<p>위에서 설명한대로 검사규칙들을 설정할수 있도록 해줍니다:</p>

<ul>
<li><a href="#validationrules">검사규칙 설정 Setting Validation Rules</a></li>
<li><a href="#savingtoconfig">검사규칙을 그룹화하여 설정파일에 저장하기 Saving Groups of Validation Rules to a Config File</a></li>
</ul>


<h2>$this->form_validation->run();</h2>

<p>검사루틴을 실행합니다.  성공하면TRUE 를 실패하면 FALSE를 리턴합니다. 필요할때는 검사규칙 그룹이름을 파라미터로 넘겨줄수 있습니다. 자세한 설명은 <a href="#savingtoconfig">검사규칙을 그룹화하여 설정파일에 저장하기 를 참조해주세요 </a>.</p>


<h2>$this->form_validation->set_message();</h2>

<p>여러분만의 에러메세지를 설정할수 있습니다.위의  <a href="#settingerrors">에러메세지 설정(Setting Error Messages</a>) 을 참고해 주세요.</p>


<p>&nbsp;</p>

<a name="helperreference"></a>
<h1>헬퍼 레퍼런스 Helper Reference</h1>

<p>아래 헬퍼 함수들은 폼을 포함하고 있는 뷰 파일에서 사용하실 수 있습니다.  이 함수들은 절차적 함수(객체아님)들 이기 때문에 $this->form_validation를 붙일 필요가 없습니다.</p>

<h2>form_error()</h2>

<p>함수로 넘겨진 필드명과 관련된 개별 에러메세지를 출력합니다. 예:</p>

<code>&lt;?php echo form_error('username'); ?></code>

<p>필요하다면 에러 구분자를 설정할수 있습니다.위의  <a href="#errordelimiters">에러구분자 변경(Changing the Error Delimiters</a>) 섹션을 참고하세요.</p>



<h2>validation_errors()</h2>
<p>모든 에러메세지를 문자열로 출력합니다:  예:</p>

<code>&lt;?php echo validation_errors(); ?></code>

<p>필요하다면 에러 구분자를 설정할수 있습니다.위의 <a href="#errordelimiters">에러구분자 변경(Changing the Error Delimiters</a>) 섹션을 참고하세요.</p>



<h2>set_value()</h2>

<p>input 이나 textarea 에 값을 설정합니다.이때 <strong>반드시</strong> 필드이름을 함수 첫번째 파라미터로 넘겨주어야 합니다. 필요하다면 두번째 파라미터로 기본값을 설정할 수 있습니다. 예:</p>

<code>&lt;input type="text" name="quantity" value="<dfn>&lt;?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>

<p>위 예제에서는 폼이 처음 로드될때 기본값이 "0" 이 설정되어 보여질 것입니다. </p>

<h2>set_select()</h2>

<p><dfn>&lt;select></dfn> 를 사용할때 이 함수는 선택된 아이템을 표시하도록 해 줍니다.첫번째 파라미터는 반드시 select 의 name 을 포함해야 하며, 두번째 파라미터는 각 아이템의 값을 반드시 포함해야 합니다. 그리고 필요하다면 세번째 파라미터를 통해 특정 아이템을 기본값으로 지정할 수 있습니다(불린 TRUE/FALSE 를 사용합니다).</p>

<p>예:</p>

<code>
&lt;select name="myselect"><br />
&lt;option value="one" <dfn>&lt;?php echo  set_select('myselect', 'one', TRUE); ?></dfn> >One&lt;/option><br />
&lt;option value="two" <dfn>&lt;?php echo  set_select('myselect', 'two'); ?></dfn> >Two&lt;/option><br />
&lt;option value="three" <dfn>&lt;?php echo  set_select('myselect', 'three'); ?></dfn> >Three&lt;/option><br />
&lt;/select>
</code>


<h2>set_checkbox()</h2>

<p>체크박스를 전송될 당시의 상태로 보여지도록 합니다.첫번째 파라미터는 체크박스 이름을 포함해야하며, 두번째 파라미터는 그 값을 반드시 포함해야 합니다. 필요하다면 세번째 파라미터를 통해서 기본값을 설정할 수 있습니다.(불린 TRUE/FALSE 를 사용합니다)</p>
<p>예:</p>
<code>&lt;input type="checkbox" name="mycheck[]" value="1" <dfn>&lt;?php echo set_checkbox('mycheck[]', '1'); ?></dfn> /><br />
&lt;input type="checkbox" name="mycheck[]" value="2" <dfn>&lt;?php echo set_checkbox('mycheck[]', '2'); ?></dfn> /></code>


<h2>set_radio()</h2>

<p>라디오 버튼을전송될 당시의 상태로 보여지도록 합니다. 이 함수는 위 <strong>set_checkbox()</strong> 함수와 동일합니다.</p>

<code>&lt;input type="radio" name="myradio" value="1" <dfn>&lt;?php echo  set_radio('myradio', '1', TRUE); ?></dfn> /><br />
&lt;input type="radio" name="myradio" value="2" <dfn>&lt;?php echo  set_radio('myradio', '2'); ?></dfn> /></code>



</div>
<!-- END CONTENT -->


<div id="footer">
<p>
Previous Topic:&nbsp;&nbsp;<a href="file_uploading.html">File Uploading Class</a>
&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
Next Topic:&nbsp;&nbsp;<a href="ftp.html">FTP Class</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 - 2011 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
</div>

</body>
</html>